package task1.core;

import task1.classes.Bus;
import task1.classes.Car;
import task1.classes.GreetingService;
import task1.classes.Transport;
import task1.core.XmlBeanDefinitionReader.ParserTypes;

public class MainApp {
	public static void main(String[] args) {
		GenericXmlApplicationContext context = new GenericXmlApplicationContext();
		context.load(MainApp.class.getResource("/GS_SpringXMLConfig.xml").getPath());
		context.setValidating(true);
		context.setParserType(ParserTypes.SAX);

		BeanFactory factory = context.getBeanFactory();

		GreetingService greetingService = 
				(GreetingService) factory.getBean("greetingService", GreetingService.class);
		System.out.println(greetingService.getMessage());
		
		Bus bus = 
				(Bus) factory.getBean("bus", Transport.class);
		System.out.println(bus.getMessage());
		
		Bus bus2 = 
				(Bus) factory.getBean("bus2", Transport.class);
		System.out.println(bus2.getMessage());
		
		Car car = 
				(Car) factory.getBean("car", Transport.class);
		System.out.println(car.toString());
	}
}